# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rexml
_gemname=rexml
# Keep version in sync with "Bundled gems" (https://stdgems.org) for the
# packaged Ruby version.
pkgver=3.2.9
pkgrel=0
pkgdesc="An XML toolkit for Ruby"
url="https://github.com/ruby/rexml"
arch="noarch"
license="BSD-2-Clause"
depends="ruby"
checkdepends="
	ruby-test-unit
	ruby-test-unit-ruby-core
	"
makedepends="ruby-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/ruby/rexml/archive/v$pkgver/ruby-rexml-$pkgver.tar.gz"
builddir="$srcdir/$_gemname-$pkgver"

[ "$CARCH" = "s390x" ] && options="!check"

build() {
	gem build $_gemname.gemspec
}

check() {
	ruby test/run.rb
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	local geminstdir="$gemdir/gems/$_gemname-$pkgver"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname

	# Remove unnecessary files and rubbish...
	cd "$gemdir"
	rm -r cache build_info extensions plugins

	cd "$geminstdir"
	rm -r doc LICENSE* *.md
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')"/doc
}

sha512sums="
9feba575fb9c8f7bb9f2d2d03fa67a011c0d52604630ab3b9f6acd99a86d2f520647d58134ae5cf2068e1f87e9c4ba9b98814e437c158bab0f7a4f368e4be486  ruby-rexml-3.2.9.tar.gz
"
